<template>
    <div class="asset-info-panel">
        <div class="asset-cards-container">
            <div class="asset-card building-card">
                <div class="card-content">
                    <div class="icon-container">
                        <el-icon :size="22" class="icon-building"><OfficeBuilding /></el-icon>
                    </div>
                    <div class="info-container">
                        <span class="label">楼宇总数</span>
                        <div class="value-container">
                            <span class="value">{{ animatedBuildings }}</span>
                            <span class="trend up">
                                <el-icon :size="12"><ArrowUp /></el-icon>
                                <span>2.5%</span>
                            </span>
                        </div>
                    </div>
                </div>
                <div class="card-glow"></div>
            </div>
            
            <div class="asset-card unit-card">
                <div class="card-content">
                    <div class="icon-container">
                        <el-icon :size="22" class="icon-unit"><Grid /></el-icon>
                    </div>
                    <div class="info-container">
                        <span class="label">单元总数</span>
                        <div class="value-container">
                            <span class="value">{{ animatedUnits }}</span>
                            <span class="trend up">
                                <el-icon :size="12"><ArrowUp /></el-icon>
                                <span>4.2%</span>
                            </span>
                        </div>
                    </div>
                </div>
                <div class="card-glow"></div>
            </div>
            
            <div class="asset-card device-card">
                <div class="card-content">
                    <div class="icon-container">
                        <el-icon :size="22" class="icon-device"><Cpu /></el-icon>
                    </div>
                    <div class="info-container">
                        <span class="label">设备总数</span>
                        <div class="value-container">
                            <span class="value">{{ animatedDevices }}</span>
                            <span class="trend up">
                                <el-icon :size="12"><ArrowUp /></el-icon>
                                <span>6.8%</span>
                            </span>
                        </div>
                    </div>
                </div>
                <div class="card-glow"></div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { defineProps, computed } from 'vue';
import { OfficeBuilding, Grid, Cpu, ArrowUp, ArrowDown } from '@element-plus/icons-vue';
import { useCountUp } from '@/composables/useCountUp';

const props = defineProps({
    stats: {
        type: Object,
        required: true,
        default: () => ({ buildings: 0, units: 0, devices: 0 }),
    }
});

const animatedBuildings = useCountUp(() => props.stats.buildings || 0);
const animatedUnits = useCountUp(() => props.stats.units || 0);
const animatedDevices = useCountUp(() => props.stats.devices || 0);
</script>

<style scoped>
@keyframes pulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

.asset-info-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    padding: 10px 0;
}

.asset-cards-container {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
}

.asset-card {
    position: relative;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px 10px;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1;
}

.card-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
}

.card-glow {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, rgba(0, 0, 0, 0) 70%);
    opacity: 0;
    z-index: 1;
    transition: opacity 0.3s ease;
}

.asset-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.asset-card:hover .card-glow {
    opacity: 0.8;
    animation: pulse 2s infinite;
}

.building-card {
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.2), rgba(0, 92, 158, 0.4));
    border: 1px solid rgba(0, 229, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 229, 255, 0.15);
}

.unit-card {
    background: linear-gradient(135deg, rgba(255, 197, 61, 0.2), rgba(255, 149, 0, 0.4));
    border: 1px solid rgba(255, 197, 61, 0.3);
    box-shadow: 0 4px 12px rgba(255, 197, 61, 0.15);
}

.device-card {
    background: linear-gradient(135deg, rgba(170, 0, 255, 0.2), rgba(120, 0, 170, 0.4));
    border: 1px solid rgba(170, 0, 255, 0.3);
    box-shadow: 0 4px 12px rgba(170, 0, 255, 0.15);
}

.icon-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
    margin-bottom: 8px;
}

.building-card .icon-container {
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.5);
}

.unit-card .icon-container {
    box-shadow: 0 0 12px rgba(255, 197, 61, 0.5);
}

.device-card .icon-container {
    box-shadow: 0 0 12px rgba(170, 0, 255, 0.5);
}

.icon-building {
    color: #00e5ff;
    filter: drop-shadow(0 0 5px rgba(0, 229, 255, 0.7));
}

.icon-unit {
    color: #ffc53d;
    filter: drop-shadow(0 0 5px rgba(255, 197, 61, 0.7));
}

.icon-device {
    color: #aa00ff;
    filter: drop-shadow(0 0 5px rgba(170, 0, 255, 0.7));
}

.info-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.label {
    font-size: 13px;
    color: #aed4ff;
    margin-bottom: 4px;
}

.value-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.value {
    font-size: 24px;
    font-weight: bold;
    color: #fff;
    font-family: 'Digital-7 Mono', sans-serif;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.7);
}

.trend {
    display: flex;
    align-items: center;
    font-size: 11px;
    font-weight: bold;
    padding: 1px 4px;
    border-radius: 8px;
}

.trend.up {
    color: #52c41a;
    background: rgba(82, 196, 26, 0.1);
}

.trend.down {
    color: #ff4d4f;
    background: rgba(255, 77, 79, 0.1);
}
</style> 